package com.guigu.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.guigu.mapper.Pmapper;
import com.guigu.pojo.Product;
import com.guigu.service.Pservice;
import com.guigu.vo.Pojo;
import com.guigu.vo.Vo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Iterator;
import java.util.List;

@Service
public class PserviceImpl extends ServiceImpl<Pmapper, Product> implements Pservice {
    @Autowired
    private Pmapper pmapper;

    @Override
    public Pojo<Product> selectProduct(Vo vo, int pageNo, int pageSize) {
        //设置分页参数
        PageHelper.startPage(pageNo, pageSize);
        //查询数据
        List<Product> productList = pmapper.selectAll(vo);
        //封装数据
        PageInfo<Product> pageInfo = new PageInfo<>(productList);
        //转换Pojo
        Pojo<Product> pojo = new Pojo<>();
        pojo.setRows(pageInfo.getList());
        pojo.setTotal(pageInfo.getTotal());
        return pojo;
    }

    @Override
    public Pojo<Product> selectProductByCondition(Vo vo, int pageNo, int pageSize) {
        return null;
    }

}
